Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][io] Close the kafka source connector got stuck #20698

Merged
merged 7 commits into from
Jun 30, 2023

Conversation

poorbarcode
Copy link
Contributor

@poorbarcode poorbarcode commented Jun 30, 2023

Motivation

#19880 (comment) When Kafka connector is closing, it waits for the runnerThread to stop, but the task-close is running at the same thread, so it will be stuck.

Modifications

run close in another thread.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: x

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jun 30, 2023
@@ -64,6 +66,7 @@ public abstract class KafkaAbstractSource<V> extends PushSource<V> {
private volatile boolean running = false;
private KafkaSourceConfig kafkaSourceConfig;
private Thread runnerThread;
private final Executor executor = Executors.newSingleThreadExecutor();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to set a thread name for debugging purpose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And when the executor will be closed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to set a thread name for debugging purpose.

fixed

And when the executor will be closed?

changed it to a static variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already remove the executor, and just new one thread if needed

@poorbarcode poorbarcode changed the title [fix][io] Close the kafka source connector close stuck [fix][io] Close the kafka source connector got stuck Jun 30, 2023
@mattisonchao
Copy link
Member

We only use this thread once. Maybe we can new a thread and then run the close task?

@codecov-commenter
Copy link

Codecov Report

Merging #20698 (e64e835) into master (0e60340) will increase coverage by 0.56%.
The diff coverage is 80.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #20698      +/-   ##
============================================
+ Coverage     72.60%   73.17%   +0.56%     
- Complexity    32018    32105      +87     
============================================
  Files          1855     1871      +16     
  Lines        138569   138964     +395     
  Branches      15250    15283      +33     
============================================
+ Hits         100605   101682    +1077     
+ Misses        29945    29239     -706     
- Partials       8019     8043      +24     
Flag Coverage Δ
inttests 24.14% <34.81%> (+0.03%) ⬆️
systests 25.10% <19.25%> (?)
unittests 72.42% <80.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ava/org/apache/pulsar/admin/cli/CmdNamespaces.java 76.17% <0.00%> (-0.08%) ⬇️
.../service/SystemTopicBasedTopicPoliciesService.java 76.48% <50.00%> (-1.19%) ⬇️
...ar/common/naming/TopicBundleAssignmentFactory.java 66.66% <66.66%> (ø)
...pulsar/broker/admin/impl/PersistentTopicsBase.java 64.33% <68.18%> (+0.20%) ⬆️
...xtensions/channel/ServiceUnitStateChannelImpl.java 84.22% <71.42%> (-0.09%) ⬇️
...n/java/org/apache/pulsar/admin/cli/CliCommand.java 57.95% <71.42%> (-1.60%) ⬇️
...rg/apache/pulsar/io/kafka/KafkaAbstractSource.java 69.71% <71.42%> (+0.65%) ⬆️
.../metadata/bookkeeper/PulsarRegistrationClient.java 80.85% <81.11%> (-4.11%) ⬇️
.../pulsar/common/topics/TopicCompactionStrategy.java 90.90% <83.33%> (-9.10%) ⬇️
...he/pulsar/broker/admin/v2/NonPersistentTopics.java 62.55% <86.95%> (+0.63%) ⬆️
... and 14 more

... and 164 files with indirect coverage changes

@poorbarcode
Copy link
Contributor Author

The failed OWASP dependency check will be fixed by #20699

@poorbarcode poorbarcode merged commit c5237ea into apache:master Jun 30, 2023
poorbarcode added a commit that referenced this pull request Jun 30, 2023
Motivation: #19880 (comment) When Kafka connector is closing, it waits for the `runnerThread` to stop, but the task-close is running at the same thread, so it will be stuck.

Modifications: run `close` in another thread.
(cherry picked from commit c5237ea)
poorbarcode added a commit that referenced this pull request Jun 30, 2023
Motivation: #19880 (comment) When Kafka connector is closing, it waits for the `runnerThread` to stop, but the task-close is running at the same thread, so it will be stuck.

Modifications: run `close` in another thread.
(cherry picked from commit c5237ea)
@poorbarcode poorbarcode deleted the fix/kafka_source_stuck branch July 1, 2023 21:58
Technoboy- pushed a commit that referenced this pull request Jul 3, 2023
Motivation: #19880 (comment) When Kafka connector is closing, it waits for the `runnerThread` to stop, but the task-close is running at the same thread, so it will be stuck.

Modifications: run `close` in another thread.
tisonkun pushed a commit to tisonkun/pulsar that referenced this pull request Jul 12, 2023
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jul 17, 2023
Motivation: apache#19880 (comment) When Kafka connector is closing, it waits for the `runnerThread` to stop, but the task-close is running at the same thread, so it will be stuck.

Modifications: run `close` in another thread.
(cherry picked from commit c5237ea)
(cherry picked from commit 3a2e593)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants